<template>
  <div class="app-container">
    <div class="app-header">
      <h1>Vue3 PDF查看器示例</h1>
      <div class="mode-selector">
        <button 
          :class="{ active: mode === 'demo' }"
          @click="mode = 'demo'"
        >
          功能演示
        </button>
        <button 
          :class="{ active: mode === 'simple' }"
          @click="mode = 'simple'"
        >
          简单使用
        </button>
      </div>
    </div>

    <!-- 功能演示模式 -->
    <PdfViewerExample v-if="mode === 'demo'" />

    <!-- 简单使用模式 -->
    <div v-else class="simple-mode">
      <div class="pdf-selector">
        <button 
          v-for="file in pdfFiles" 
          :key="file.path"
          :class="{ active: currentPdf === file.path }"
          @click="currentPdf = file.path"
        >
          {{ file.name }}
        </button>
      </div>
      <PdfWithThumbnails :src="currentPdf" />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import PdfWithThumbnails from "./components/PdfWithThumbnails.vue";
import PdfViewerExample from "./components/PdfViewerExample.vue";

/**
 * 主应用组件
 * @author Ning,Li
 */

// 模式选择：demo（功能演示）或 simple（简单使用）
const mode = ref('demo');

// PDF文件列表
const pdfFiles = [
  { name: '测试文档1', path: '/test1.pdf' },
  { name: '测试文档2', path: '/test2.pdf' }
];

// 当前选中的PDF
const currentPdf = ref('/test2.pdf');
</script>

<style>
.app-container {
  max-width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: #fff;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
  margin: 0;
  color: #333;
  font-size: 24px;
  font-weight: 600;
}

.mode-selector {
  display: flex;
  gap: 8px;
}

.mode-selector button {
  padding: 8px 16px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #495057;
  transition: all 0.2s ease;
}

.mode-selector button:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.mode-selector button.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.simple-mode {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.pdf-selector {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-selector button {
  padding: 8px 16px;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.pdf-selector button:hover {
  background-color: #e0e0e0;
}

.pdf-selector button.active {
  background-color: #42b983;
  color: white;
  border-color: #42b983;
}

.simple-mode .pdfjs-viewer-root {
  height: calc(100vh - 150px) !important;
}

/* 全局样式重置 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100vh;
}
</style>
